<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue js动画和velocity</title>
    <script charset="UTF-8" src="js/vue.js"></script>
    <script src="js/velocity.js"></script>
</head>
<body>
<div id="app">
    <transition name="fade"
                @before-enter="handleBeforeEnter"
                @enter="handleEnter"
                @after-enter="handleAfterEnter">
        <div v-if="show">
            hello World
        </div>
    </transition>
    <button @click="handleClick">切换</button>
</div>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
            show: true
        },
        methods: {
            handleClick: function () {
                this.show = !this.show;
            },
            handleBeforeEnter: function (el) {
                // js动画
                // el.style.color="red"

                el.style.opacity = 0;
            },
            handleEnter: function (el, done) {
                // js动画
                // setTimeout(()=>{
                //     el.style.color="green"
                // },2000)
                // setTimeout(()=>{
                //     done()
                // },4000)
                // velocity动画
                Velocity(el,{opacity:1},{duration:1000,complete:done});
            },
            handleAfterEnter: function (el) {
                // js动画
                // el.style.color="#000"

                alert("动画结束");
            }
        }
    });
</script>
</body>
</html>